import request from '@/utils/request'
const startUrl = '/administrator'

/**
 * 用户登录
 * @param username 用户名
 * @param password 密码
 */
export const administratorLogin = (username, password) =>
    request.post(startUrl+'/login',{username,password})

/**
 * 当前登录管理员信息
 */
export const currentAdministratorInfo = (administratorStore) =>
    request.get(startUrl+'/current',{
        headers: {
            'Administrator-Token': administratorStore.$state.jwtEntity.jwt,
            'Administrator-Secret-Key': administratorStore.$state.jwtEntity.signKeyStr
        }
    })

/**
 * 更新管理员密码
 */
export const updateAdministratorPassword = (administratorStore, password) =>
    request.post(startUrl+'/update/password',{password},{
        headers: {
            'Administrator-Token': administratorStore.$state.jwtEntity.jwt,
            'Administrator-Secret-Key': administratorStore.$state.jwtEntity.signKeyStr
        }
    })

/**
 * 创建新的管理员
 * @param administratorStore
 * @param username
 * @param password
 * @param realName
 * @param gender
 * @param phone
 * @param email
 * @param university
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const createAdministrator = (administratorStore, username, password, realName, gender, phone, email, university) =>
    request.post(startUrl+'/create',{ username, password, realName, gender, phone, email, university},{
        headers: {
            'Administrator-Token': administratorStore.$state.jwtEntity.jwt,
            'Administrator-Secret-Key': administratorStore.$state.jwtEntity.signKeyStr
        }
    })
/**
 * 查看所管辖的管理员列表
 * @param administratorStore
 * @param searchValue
 */
export const listAdministrator = (administratorStore, searchValue) =>
    request.get(startUrl+'/management/list',{
        params: {
            search_value: searchValue
        },
        headers: {
            'Administrator-Token': administratorStore.$state.jwtEntity.jwt,
            'Administrator-Secret-Key': administratorStore.$state.jwtEntity.signKeyStr
        }
    })

/**
 * 删除管理员
 * @param administratorStore
 * @param administrator_id
 */
export const deleteAdministratorApi = (administratorStore,administrator_id) =>
    request.get(startUrl+'/delete',{
        params: {
            administrator_id: administrator_id
        },
        headers: {
            'Administrator-Token': administratorStore.$state.jwtEntity.jwt,
            'Administrator-Secret-Key': administratorStore.$state.jwtEntity.signKeyStr
        }
    })

/**
 * 活动列表
 * @param administratorStore
 * @param activityName
 * @param maxNum
 * @param applicant
 * @param type
 * @param reviewer
 * @param activityStatus
 * @param university
 */
export const listActivityAdministrator = (administratorStore,activityName,maxNum,applicant,type,reviewer,activityStatus,university) =>
    request.post(startUrl+'/activity/list',{activityName,maxNum,applicant,type,reviewer,activityStatus,university},{
        headers: {
            'Administrator-Token': administratorStore.$state.jwtEntity.jwt,
            'Administrator-Secret-Key': administratorStore.$state.jwtEntity.signKeyStr
        }
    })

/**
 * 审核活动
 * @param administratorStore
 * @param activityId
 * @param reviewStatus
 */
export const reviewActivity = (administratorStore, activityId, reviewStatus) =>
    request.get(startUrl + '/activity/review',{
        params: {
            activity_id: activityId,
            review_status: reviewStatus,
        },
        headers: {
            'Administrator-Token': administratorStore.$state.jwtEntity.jwt,
            'Administrator-Secret-Key': administratorStore.$state.jwtEntity.signKeyStr
        }

    })

/**
 * 更新活动
 * @param administratorStore
 * @param id
 * @param activityName
 * @param description
 * @param maxNum
 * @param expirationTime
 * @param type
 */
export const updateActivity = (administratorStore, id, activityName, description, maxNum, expirationTime, type) =>
    request.post(startUrl + '/activity/update', {id, activityName, description, maxNum, expirationTime, type}, {
        headers: {
            'Administrator-Token': administratorStore.$state.jwtEntity.jwt,
            'Administrator-Secret-Key': administratorStore.$state.jwtEntity.signKeyStr
        }
    })

/**
 * 管理员创建活动
 */

export const createActivity = (administratorStore, activityName, description, maxNum, expirationTime, type) =>
    request.post(startUrl + '/activity/create', {activityName, description, maxNum, expirationTime, type}, {
        headers: {
            'Administrator-Token': administratorStore.$state.jwtEntity.jwt,
            'Administrator-Secret-Key': administratorStore.$state.jwtEntity.signKeyStr
        }
    })

/**
 * 删除活动
 * @param administratorStore
 * @param activityId
 */
export const deleteActivityApi = (administratorStore, activityId) =>
    request.get(startUrl + '/activity/delete',{
        params: {
            activity_id: activityId,
        },
        headers: {
            'Administrator-Token': administratorStore.$state.jwtEntity.jwt,
            'Administrator-Secret-Key': administratorStore.$state.jwtEntity.signKeyStr
        }

    })


/**
 * 分页获取整个活动的评分
 * @param administratorStore
 * @param current
 * @param pageSize
 * @param activityId
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const pageAllGradeAdmin = (administratorStore, current, pageSize, activityId) =>
    request.get(startUrl + '/grade/all/page',{
        params: {
            'current': current,
            'page_size': pageSize,
            'activity_id': activityId

        },
        headers: {
            'Administrator-Token': administratorStore.$state.jwtEntity.jwt,
            'Administrator-Secret-Key': administratorStore.$state.jwtEntity.signKeyStr
        }
    })

/**
 * 分页获取整个活动的反馈
 * @param administratorStore
 * @param current
 * @param pageSize
 * @param activityId
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const pageAllFeedback = (administratorStore, current, pageSize, activityId) =>
    request.get(startUrl + '/feedback/all/page',{
        params: {
            'current': current,
            'page_size': pageSize,
            'activity_id': activityId

        },
        headers: {
            'Administrator-Token': administratorStore.$state.jwtEntity.jwt,
            'Administrator-Secret-Key': administratorStore.$state.jwtEntity.signKeyStr
        }
    })